//
//  HelloWorldLayer.m
//  Starter
//
//  Created by iD Student on 6/27/12.
//  Copyright __MyCompanyName__ 2012. All rights reserved.
//


// Import the interfaces
#import "HelloWorldLayer.h"

// HelloWorldLayer implementation
@implementation HelloWorldLayer

+(CCScene *) scene
{
	// 'scene' is an autorelease object.
	CCScene *scene = [CCScene node];
	
	// 'layer' is an autorelease object.
	HelloWorldLayer *layer = [HelloWorldLayer node];
	
	// add layer as a child to scene
	[scene addChild: layer];
	
	// return the scene
	return scene;
}

// on "init" you need to initialize your instance
-(id) init
{
	// always call "super" init
	// Apple recommends to re-assign "self" with the "super" return value
	if( (self=[super init])) {
		hero=[CCSprite spriteWithFile:@"pic.png"];
        size=[[CCDirector sharedDirector]winSize];
        [hero setPosition:ccp(size.width/2, size.height/2)];
        [self addChild:hero];
        [hero setScale:0.4];
	}
	return self;
}
-(void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event   {
    UITouch *touch=[touches anyObject];
    touchLocation=ccp([touch locationInView:[touch view]].x, 360-[touch locationInView:[touch view]].y);
    id move=[CCMoveTo actionWithDuration:1 position:touchLocation];
    [hero runAction:[CCSequence actions:move, nil]];
}

// on "dealloc" you need to release all your retained objects
- (void) dealloc
{
	// in case you have something to dealloc, do it in this method
	// in this particular example nothing needs to be released.
	// cocos2d will automatically release all the children (Label)
	
	// don't forget to call "super dealloc"
	[super dealloc];
}
-(float)determineTime:(float)velocity{
    ccpDistance(hero.position, touchLocation);
    
}
@end
